package org.seckill.service;

import java.util.List;

import org.seckill.dto.Exposer;
import org.seckill.dto.SeckillExecution;
import org.seckill.entity.Seckill;
import org.seckill.exception.RepeatKillException;
import org.seckill.exception.SeckillCloseException;
import org.seckill.exception.SeckillException;

public interface SeckillService {
	/**
	 * 查询所有秒杀
	 * 
	 * @return
	 */
	List<Seckill> listSeckills();

	/**
	 * 查询单个秒杀记录
	 * 
	 * @param seckillId
	 * @return
	 */
	Seckill getSeckillById(long seckillId);

	/**
	 * 秒杀开启是输出秒杀接口地址,否则输出系统时间和秒杀时间
	 * 
	 * @param seckillId
	 * @return {@link Exposer}
	 */
	Exposer exportSeckillUrl(long seckillId);

	/**
	 * 使用spring事务管理
	 * @param seckillId
	 * @param userPhone
	 * @param md5
	 * @return {@link SeckillExecution}
	 * @throws SeckillException
	 * @throws RepeatKillException
	 * @throws SeckillCloseException
	 */
	SeckillExecution executeSeckill(long seckillId, long userPhone, String md5)
			throws SeckillException, RepeatKillException, SeckillCloseException;
	
	/**
	 * 使用存储过程
	 * @param seckillId
	 * @param userPhone
	 * @param md5
	 * @return
	 * @throws SeckillException
	 * @throws RepeatKillException
	 * @throws SeckillCloseException
	 */
	SeckillExecution executeSeckillProcedure(long seckillId, long userPhone, String md5);
}
